﻿using System;
namespace Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000 {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="kam1", Namespace="http://producers.ehma-10000000.xtee.riik.ee/producer/ehma-10000000", Target=typeof(Kam1))]
    public class Kam1Serializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IKam1 clazz;
        
        public Kam1Serializer(IKam1 clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("gametype");
            if (clazz.Gametype!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Gametype))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Gametype");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("totalbet");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Totalbet))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("totalwin");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Totalwin))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("playerno");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "nonNegativeInteger");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdNonNegativeInteger(((decimal)(clazz.Playerno))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="gametype") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>kam1>gametype");
                }
                clazz.Gametype = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("gametype")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>kam1>gametype", Reader.LocalName);
            }
            if (Reader.LocalName=="totalbet") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>kam1>totalbet");
                }
                clazz.Totalbet = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("totalbet")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>kam1>totalbet", Reader.LocalName);
            }
            if (Reader.LocalName=="totalwin") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>kam1>totalwin");
                }
                clazz.Totalwin = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("totalwin")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>kam1>totalwin", Reader.LocalName);
            }
            if (Reader.LocalName=="playerno") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>kam1>playerno");
                }
                clazz.Playerno = new global::Xtee.Core.Schema.XsdNonNegativeInteger(Reader.ReadElementString("playerno")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>kam1>playerno", Reader.LocalName);
            }
        }
    }
}
